package subject_set.top101;

/**
 * @author haomin
 * @date 2022/11/01 21:41
 **/
public class BM31 {
    public class Solution {
        boolean isSymmetrical(TreeNode pRoot) {
            if(pRoot == null) return true;
            return isEquals(pRoot.left, pRoot.right);
        }
        private boolean isEquals(TreeNode l, TreeNode r){
            if(l == null && r == null) return true;
            if(l == null || r == null) return false;
            return l.val == r.val &&
                    isEquals(l.left, r.right) && isEquals(l.right, r.left);
        }
    }
}